package com.blrs.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.blrs.domain.vo.BusinessMainClassVo;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.blrs.common.annotation.Log;
import com.blrs.common.core.controller.BaseController;
import com.blrs.common.core.domain.AjaxResult;
import com.blrs.common.enums.BusinessType;
import com.blrs.domain.EnterpriseShareLog;
import com.blrs.service.enterprise.sharelog.IEnterpriseShareLogService;
import com.blrs.common.utils.poi.ExcelUtil;
import com.blrs.common.core.page.TableDataInfo;

/**
 * 客户资源共享日志Controller
 * 
 * @author wang.chao
 * @date 2024-04-18
 */
@RestController
@RequestMapping("/enterprisesharelog/log")
public class EnterpriseShareLogController extends BaseController
{
    @Autowired
    private IEnterpriseShareLogService enterpriseShareLogService;

    /**
     * 查询客户资源共享日志列表
     */
    @GetMapping("/list")
    public TableDataInfo list(EnterpriseShareLog enterpriseShareLog)
    {
        startPage();
        List<EnterpriseShareLog> list = enterpriseShareLogService.selectEnterpriseShareLogList(enterpriseShareLog);
        return getDataTable(list);
    }

    /**
     * 导出客户资源共享日志列表
     */
    @Log(title = "客户资源共享日志", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EnterpriseShareLog enterpriseShareLog)
    {
        List<EnterpriseShareLog> list = enterpriseShareLogService.selectEnterpriseShareLogList(enterpriseShareLog);
        ExcelUtil<EnterpriseShareLog> util = new ExcelUtil<EnterpriseShareLog>(EnterpriseShareLog.class);
        util.exportExcel(response, list, "客户资源共享日志数据");
    }

    /**
     * 获取客户资源共享日志详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(enterpriseShareLogService.selectEnterpriseShareLogById(id));
    }

    /**
     * 新增客户资源共享日志
     */
    @Log(title = "客户资源共享日志", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EnterpriseShareLog enterpriseShareLog) throws NoSuchFieldException, IllegalAccessException
    {
        return toAjax(enterpriseShareLogService.insertEnterpriseShareLog(enterpriseShareLog));
    }

    /**
     * 修改客户资源共享日志
     */
    @Log(title = "客户资源共享日志", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EnterpriseShareLog enterpriseShareLog)
    {
        return toAjax(enterpriseShareLogService.updateEnterpriseShareLog(enterpriseShareLog));
    }

    /**
     * 删除客户资源共享日志
     */
    @Log(title = "客户资源共享日志", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(enterpriseShareLogService.deleteEnterpriseShareLogByIds(ids));
    }
}
